include ../../../../config/kern.conf

PRE		= ../../../../
TARGET	= ${BOOTIMG}
#LDFLAGS	= -melf_i386 --oformat binary -Ttext 0x100000
LDFLAGS	= -melf_i386

all: ${TARGET}

${TARGET}: ksetup.o loader.o
	ld ${LDFLAGS} -T linker.ld -o ${PRE}${TARGET} loader.o ksetup.o ktty.o kprintf.o segment.o frame.o pagem.o pci.o
#start.bin: boot1.bin boot0.asm
#	nasm -fbin boot0.asm -o ${PRE}${TARGET}
	
#boot1.bin: ksetup.o boot1.asm 
#	nasm -fbin boot1.asm -o boot1.bin
loader.o: loader.s
	as --32  -o loader.o loader.s

ksetup.o:	ksetup.c
	gcc ${CFLAGS} -o ktty.o ktty.c
	gcc ${CFLAGS} -o kprintf.o kprintf.c
	gcc ${CFLAGS} -o segment.o segment.c
	gcc ${CFLAGS} -o frame.o frame.c
	gcc ${CFLAGS} -o pagem.o pagem.c
	gcc ${CFLAGS} -o pci.o pci.c
	gcc ${CFLAGS} -o ksetup.o ksetup.c
#	nasm ${NFLAGS} -o asetupjmp.o setupjmp.s
#	ld ${LDFLAGS} -o setup *.o
clean:
	if [ -f ${PRE}${BOOTIMG} ]; then rm ${PRE}${BOOTIMG}; fi
	for i in `ls *.bin`; do rm $$i; done
	for i in `ls *.o`; do rm $$i; done
	rm setup
